import inspect

from config.config import CONFIG_ROOT, font_cfg, text_paths, \
    base_cfg
from config.effects import get_effects
from text_renderer.corpus import *
from text_renderer.effect import *
from text_renderer.layout.extra_text_line import ExtraTextLineLayout


def train_data():
    effects = get_effects()
    return base_cfg(
        inspect.currentframe().f_code.co_name,
        layout=ExtraTextLineLayout(bottom_prob=1.0),
        # SameLineLayout(h_spacing=(0.9, 0.91)) ExtraTextLineLayout(bottom_prob=1.0)
        # 图像是否变灰色,失去颜色
        gray=True,
        # gray=False,
        corpus=[EnumCorpus(
            EnumCorpusCfg(
                text_paths=text_paths,
                filter_by_chars=False,
                filter_font=False,
                auto_load_texts=False,
                chars_file=CONFIG_ROOT / "words/result_all.txt",
                **font_cfg
            ),
        )],
        corpus_effects=Effects(OneOf(effects)),
    )


# fmt: off
# The configuration file must have a configs variable
configs = [
    # chn_data(),
    # train_data_zy650w(),
    train_data()
]

#
# # fmt: on
#
#
# def train_data_zy650w():
#     return base_cfg(
#         inspect.currentframe().f_code.co_name,
#         # layout=ExtraTextLineLayout(bottom_prob=1.0),
#         layout=SameLineLayout(h_spacing=(0.9, 0.91)),
#         # layout=SameLineLayout(),
#         # layout=ExtraTextLineLayout(),
#         # 图像是否变灰色,失去颜色
#         gray=True,
#         # gray=False,
#         corpus=[EnumCorpus(
#             EnumCorpusCfg(
#                 text_paths=text_paths,
#                 # text_paths=[READER_ROOT / "all_words/demo.txt"],
#                 # num_pick=6040126,
#                 # text_paths (List[Path]): Text file paths
#                 # items (List[str]): Texts to choice. Only works if text_paths is empty
#                 # num_pick (int): Random choice {count} item from texts
#                 # filter_font (bool): Only work when filter_by_chars is True. If True, filter font file
#                 # by intersection of font support chars with chars file
#                 filter_by_chars=True,
#                 filter_font=True,
#                 chars_file=chars_file,
#                 **font_cfg
#             ),
#         )],
#         corpus_effects=Effects(effects),
#         # corpus_effects=[Effects([]), NoEffects() ],
#         # corpus_effects=Effects(
#         #     [Padding(),
#         #      Line(0.1, color_cfg=FixedTextColorCfg()),
#         #      OneOf([DropoutRand(), DropoutVertical()]),
#         #      Padding(p=1, w_ratio=[0.2, 0.21], h_ratio=[0.7, 0.71], center=True),
#         #      ImgAugEffect(aug=iaa.Emboss(alpha=(0.9, 1.0), strength=(1.5, 1.6))),
#         #      MotionBlur()
#         #      ]
#         # ),
#         # corpus_effects =    NoEffects(),
#         # layout_effects=Effects(Line(p=0.3)),
#     )
